﻿using MongoDB.Driver.Linq;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Vav.Data.Utils
{
    public static class PageExtensions
    {
        public static IQueryable<T> GetPage<T>(this IQueryable<T> objlist, int pageIndex, int pageSize) where T : class
        {
            return objlist.Skip((pageIndex - 1) * pageSize).Take(pageSize);
        }
        public static IEnumerable<T> GetPage<T>(this IEnumerable<T> objlist, int pageIndex, int pageSize) where T : class
        {
            return objlist.Skip((pageIndex - 1) * pageSize).Take(pageSize);
        }
        public static IMongoQueryable<T> GetPage<T>(this IMongoQueryable<T> objlist, int pageIndex, int pageSize) where T : class
        {
            return objlist.Skip((pageIndex - 1) * pageSize).Take(pageSize);
        }
    }
}
